<!DOCTYPE html>
<html>

<head>
    <title>登录</title>

    <!-- 弹出框登录界面样式 -->
    <style>
        form {
            width: 280px;
            height: 180px;
            margin: 15px auto;
            padding: 20px;
            border: 1px solid #ccc;
            background-color: azure;
        }
        
        .right {
            float: right;
        }
        
        .register {
            float: right;
            margin: 10px;
            font-size: 10px;
        }
        
        .agreement {
            float: left;
            margin: 10px 25px;
            font-size: 10px;
        }
        
        p {
            float: left;
            font-size: 10px;
        }
        
        p:nth-of-type(2) {
            position: relative;
            left: 20px;
        }
        
        .box {
            display: block;
            margin-top: 50px;
        }
        
        .reset {
            margin-left: 25px;
            border-radius: 10px;
        }
        
        .login {
            float: right;
            margin-right: 25px;
            border-radius: 10px;
        }
    </style>

    <!-- 弹出框设定 -->
    <style>
        .dialog {
            display: none;
            position: fixed;
            z-index: 1;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            overflow: auto;
            background-color: rgba(0, 0, 0, 0.4);
        }
        
        .dialog-content {
            background-color: #fefefe;
            margin: 15% auto;
            border: 1px solid #888;
            width: 350px;
            height: 250px;
        }
        
        button {
            margin-top: 10px;
        }
        
        input {
            margin-bottom: 10px;
        }
    </style>

    <script>
        function showDialog() {
            document.getElementById("dialog").style.display = "block";
        }

        function closeDialog() {
            document.getElementById("dialog").style.display = "none";
        }
    </script>

    <script>
        function login() {
            // 获取用户名和密码输入框的值
            var username = document.getElementById("username").value;
            var password = document.getElementById("password").value;

            // 获取复选框数据
            var checkbox = document.getElementById("checkbox");

            // 验证用户名和密码
            if (username === "admin" && password === "123") {
                // 加载新页面
                window.location.href = "index1.html";
            } else if (!checkbox.checked) {
                // 检查复选框是否选中
                alert("请仔细阅读并勾选登录协议和隐私政策");
                return;
            } else if (username === "" || password === "") {
                // 检测用户名或密码是否为空(双等判断会进行类型转换，三等是纯比较)
                alert("用户名或密码不能为空！")
            } else {
                alert("用户名或密码错误");
            }
        }
    </script>
</head>

<body>
    <button onclick="showDialog()">登录</button>

    <div id="dialog" class="dialog">
        <div class="dialog-content">
            <!-- 弹框内容 -->
            <form action="#" method="post">
                用户名：
                <input class="right" type="text" id="username" placeholder="请输入您的用户名" maxlength="5">
                <br><br>密码：
                <input class="right" type="password" id="password" placeholder="请输入您的密码">
                <div class="register"><a href="">快速注册</a> | <a href="">忘记密码？</a></div><br>
                <div class="box">
                    <input type="reset" class="reset" value="清空">
                    <input class="login" type="button" value="登录" onclick="login()">
                </div>
                <div class="agreement">
                    <input type="checkbox" id="checkbox"> 详细阅读并接受
                    <a href="第四章/登录/协议与政策.html">登录协议</a> 和
                    <a href="第四章/登录/协议与政策.html">隐私政策</a>
                </div>
            </form>
        </div>
    </div>
</body>

</html>